/**
 * Created by JustinChow on 2016/11/4.
 */

"use strict";

const Util = require("util");
const GameObject = require("./GameObject");

const StaticBlockConfig = require("../Configs/Datas/Block.json");

function Block(objectId, owner, position, gameServer, staticId) {
    GameObject.apply(this, Array.prototype.slice.call(arguments));

    this.type = 2;
    this.staticId = staticId;
    this.staticConfig = this.loadConfig();

    this.tickSendUpdate = 0;

    this.initCollision();
}
Util.inherits(Block, GameObject);

module.exports = Block;

Block.prototype.sendUpdate = function () {
    if (this.tickSendUpdate > 10) {
        this.tickSendUpdate = 0;
        return true;
    }
    this.tickSendUpdate += 1;
    return false;
};

Block.prototype.onAdd = function () {

};

Block.prototype.onRemove = function () {

};

Block.prototype.move = function () {
    // Block No Move
};

Block.prototype.loadConfig = function () {
    if (!StaticBlockConfig[this.staticId]) return {};
    return StaticBlockConfig[this.staticId];
};
